package at.fhooe.stefanirndorfer.graphics;

import org.lwjgl.LWJGLException;

import at.fhooe.stefanirndorfer.game.Game;



public abstract class Visual {

	protected String id;

	public Visual(){
		id = this.getClass().getSimpleName() + System.nanoTime();
		setUpVisual();
	}
	
	public abstract void render();
	
	/**
	 * tell RenderManager to render this object
	 */
	void setUpVisual(){
		Game.getInstance().getRenderManager().addVisual(this);
	}
	
	/**
	 * tells RenderManager to stop rendering this object
	 * @param id
	 * @throws LWJGLException
	 */
	void tearDownVisual(String id) throws LWJGLException{
		Game.getInstance().getRenderManager().removeVisual(this);
	}
	
	/**
	 * 
	 * @return
	 */
	public String getId(){
		return id;
	}
	
	@Override
	public boolean equals(Object other) {
		if (other instanceof Visual) {
			return id.equals(((Visual) other).getId());
		}
		return super.equals(other);

	}
	
}
